package com.kin207.netty.handle.impl;

import com.kin207.netty.context.RequestContext;
import com.kin207.netty.handle.IMessageHandle;
import com.kin207.netty.msg.vo.GroupMessageReqVo;
import com.kin207.netty.msg.vo.GroupMessageVo;
import com.kin207.netty.session.Session;
import com.kin207.netty.session.SessionManagerAbs;

public class GroupMessageHandle implements IMessageHandle<GroupMessageReqVo> {

	public String name() {
		return "/msg/group";
	}

	public Class paramClass() {
		return GroupMessageReqVo.class;
	}

	public void handle(GroupMessageReqVo param) {
		RequestContext req = RequestContext.curr.get();
		Session session = req.getSession();
		SessionManagerAbs sessionManger = req.getSessionManager();
		
		String msg = new GroupMessageVo(param.getName(), session.getName(), param.getMessage()).toString();
		sessionManger.sendGroupMessage(param.getName(), msg,System.currentTimeMillis());
	}

}
